<template>
  <el-select v-model="val" clearable :disabled="disabled" placeholder="请选择" @change="onChange">
    <el-option
      v-for="item in options"
      :key="item.key"
      :label="item.label"
      :value="item.key"
    />
  </el-select>
</template>

<script>
export default {
  name: 'RelaRestrainSelect',
  props: {
    value: {
      type: String,
      default: 'onetomany'
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      options: [
        {
          key: 'onetoone',
          label: '1:1'
        },
        {
          key: 'onetomany',
          label: '1:N'
        },
        {
          key: 'manytoone',
          label: 'N:1'
        },
        {
          key: 'manytomany',
          label: 'N:N'
        }
      ],
      val: this.value
    }
  },
  methods: {
    onChange() {
      this.$emit('input', this.val)
    }
  }
}
</script>
